home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1993 September / September 93.iso / Archives / Applications / Commercial Addons / FoxBase / PlotGraph / Demo.PRG < prev    next >
Encoding:
Text File  |  1993-04-13  |  16.0 KB  |  530 lines  |  [F+PR/FOX+]

  1. *-
  2. *- Demo.PRG
  3. *-
  4. *- demonstrate features of PlotGraph XFCN
  5. *-
  6. CLEAR PROGRAM
  7. CLEAR ALL
  8. SET TALK OFF
  9. SET BELL OFF
  10. SET CONFIRM ON
  11. *- 
  12. *- make this my procedure file
  13. *-
  14. SET PROCEDURE TO demo
  15. *-
  16. *- open up resource file and load XFCN
  17. *-
  18. SET RESOURCE TO plotGraph                    && open the resource file
  19. LOAD plotGraph FUNCTION                      && load up the graph drawing XFCN
  20. *-
  21. *- initialize some constants
  22. *-
  23. STORE  256 TO mItalic
  24. STORE  512 TO mBold
  25. STORE 1024 TO mUnderLine
  26. *-
  27. *- initialize variables for options
  28. *-
  29. STORE 3 TO mGraphType
  30. STORE 2 TO mFormat
  31. STORE LEFT('Times' + SPACE(15),15) TO mGFontNam
  32. STORE 10 TO mGFontSiz
  33. STORE 1 TO mGFontSty
  34. STORE LEFT('Graph Title' + SPACE(40), 40) TO mGTitle
  35. STORE LEFT('Times' + SPACE(15),15) TO mGTFontNam
  36. STORE 12 TO mGTFontSiz
  37. STORE 2 TO mGTFontSty
  38. STORE '$' TO mCurrSym
  39. STORE 0 TO mMin
  40. STORE 0 TO mMax
  41. STORE 0 TO mFwd, mBack
  42. STORE 0 TO mEdit, mPlot, mDone
  43. STORE 0 TO mSteps
  44. STORE .t. TO mShowXAxis
  45. STORE .t. TO mShowYAxis
  46. STORE .t. TO mShowLeg
  47. STORE .t. TO mShowPct
  48. STORE .t. TO mAutoScale
  49. STORE .f. TO mCurrSymPl
  50. STORE .f. TO mShowXGrid
  51. STORE .t. TO mShowYGrid
  52. STORE 125 TO mWidth
  53. *-
  54. STORE  10 TO mOTop,mOTopX
  55. STORE  20 TO mOLeft, mOLeftX
  56. STORE 280 TO mOBottom,mOBottomX
  57. STORE 480 TO mORight, mORightX
  58. *-
  59. STORE  60 TO mGTop
  60. STORE 100 TO mGLeft
  61. STORE 260 TO mGBottom
  62. STORE 300 TO mGRight
  63. *-
  64. *- initialize variables for plotting graph
  65. *-
  66. STORE '' TO mData1, mData2                   && data to graph
  67. STORE 0 TO mNumPoints                        && number of data points on graph, or slices in pie
  68. STORE '' TO mORect                           && outer rectangle for graph
  69. STORE '' TO mGRect                           && rectangle for graph itself
  70. STORE '' TO mGOpt                            && graph options
  71. STORE '' TO mGFont                           && font + style for graph legends
  72. STORE '' TO mGTitl                           && text, font + style for graph title
  73. STORE '' TO mXLeg                            && text for X-axis legends
  74. STORE 0 TO mGMinMax                          && minimum and maximum value for line or bar graph, width of legend box for pies
  75. STORE '' TO mResult                          && will contain result of XFCN call
  76. *-
  77. *- open up data file
  78. *-
  79. SELECT 1
  80. USE sample
  81. *-
  82. *- open up data file of labels
  83. SELECT 2
  84. USE GLabels
  85. SELECT sample
  86. *-
  87. *- Initialize screens
  88. *-
  89. SCREEN 2 OFF
  90. CLEAR
  91. SCREEN 2 HEADING "Results of plotGraph" AT 40,40 TYPE 0 SIZE 290,480 PIXELS TOP LOCK
  92. *-
  93. STORE 24 TO mleadingx        && space between lines
  94. STORE 16 TO mleft1
  95. STORE 140 TO mleft2
  96. STORE 300 TO mleft3
  97. STORE 300 TO mbottom
  98. STORE 480 TO mright
  99. SCREEN 1 OFF
  100. CLEAR
  101. SCREEN 1 OFF AT 0,0 HEADING "plotGraph Options" TYPE 0 SIZE mbottom,mright PIXELS FONT 'chicago',12
  102. *-
  103. *- display an initial graph (see procedure below)
  104. *- 
  105. DO pPlotGraph
  106. *-
  107. DO WHILE .t.
  108.     STORE 0 TO mFwd, mBack, mEdit, mLabl, mPlot, mDone
  109.     *-
  110.     *- display options portion of screen
  111.     *-
  112.     SCREEN 1 TOP LOCK
  113.     *@ PIXELS 20,mleft1 SAY "Set graph options:"
  114.     *@ PIXELS 25,mleft1 TO 25, mright - mleft1
  115.     STORE 25 TO mx
  116.     *-
  117.     *- Graph heading font etc.
  118.     *-
  119.     @ PIXELS mx, mleft1 SAY "Graph title"
  120.     @ PIXELS mx, mleft2 GET mGTitle FONT 'monaco',12
  121.     STORE mx + mleadingx TO mx
  122.     @ PIXELS mx, mleft1 SAY "Graph title font"
  123.     @ PIXELS mx, mleft2 GET mGTFontNam FONT 'monaco',12
  124.     @ PIXELS mx, 260 SAY "Size"
  125.     @ PIXELS mx, COL(1) + 10 GET mGTFontSiz PICTURE '999' FONT 'monaco',12
  126.     @ PIXELS mx,COL(1) + 15 SAY "Style"
  127.     @ PIXELS mx, COL(1) + 10 GET mGTFontSty PICTURE '@^ Plain;Bold;Italic;Underline' FONT 'chicago',12
  128.     STORE mx + mleadingx TO mx
  129.     *-
  130.     *- Type of graph
  131.     *-
  132.     @ PIXELS mx, mleft1 SAY "Graph type"
  133.     @ PIXELS mx, mleft2 GET mGraphType PICTURE "@*RH Line;Bar;Pie" VALID 1000
  134.     STORE mx + mleadingx TO mx
  135.     *-
  136.     *- Outer rectangle
  137.     *-
  138.     @ PIXELS mx, mleft1 SAY "Outer rectangle"
  139.     @ PIXELS mx,mleft2 SAY "Top"
  140.     @ PIXELS mx, COL(1) + 10 GET mOTop PICTURE '9999' FONT  'monaco',12
  141.     @ PIXELS mx, COL(1) + 15 SAY "Left"
  142.     @ PIXELS mx, COL(1) + 10 GET mOLeft PICTURE '9999' FONT  'monaco',12
  143.     @ PIXELS mx, COL(1) + 15 SAY "Bottom"
  144.     @ PIXELS mx, COL(1) + 10 GET mOBottom PICTURE '9999' FONT  'monaco',12
  145.     @ PIXELS mx, COL(1) + 15 SAY "Right"
  146.     @ PIXELS mx, COL(1) + 10 GET mORight PICTURE '9999' FONT  'monaco',12
  147.     STORE mx + mleadingx TO mx
  148.     *-
  149.     *- Graph rectangle
  150.     *-
  151.     @ PIXELS mx, mleft1 SAY "Graph rectangle"
  152.     @ PIXELS mx, mleft2 SAY "Top"
  153.     @ PIXELS mx, COL(1) + 10 GET mGTop PICTURE '9999' FONT  'monaco',12
  154.     @ PIXELS mx, COL(1) + 15 SAY "Left"
  155.     @ PIXELS mx, COL(1) + 10 GET mGLeft PICTURE '9999' FONT  'monaco',12
  156.     @ PIXELS mx, COL(1) + 15 SAY "Bottom"
  157.     @ PIXELS mx, COL(1) + 10 GET mGBottom PICTURE '9999' FONT  'monaco',12
  158.     @ PIXELS mx, COL(1) + 15 SAY "Right"
  159.     @ PIXELS mx, COL(1) + 10 GET mGRight PICTURE '9999' FONT  'monaco',12
  160.     STORE mx + mleadingx TO mx
  161.     *-
  162.     *- Graph font etc.
  163.     *-
  164.     @ PIXELS mx, mleft1 SAY "Graph font"
  165.     @ PIXELS mx, mleft2 GET mGFontNam FONT 'monaco',12
  166.     @ PIXELS mx, 260 SAY "Size"
  167.     @ PIXELS mx, COL(1) + 10 GET mGFontSiz PICTURE '999' FONT 'monaco',12
  168.     @ PIXELS mx,COL(1) + 15 SAY "Style"
  169.     @ PIXELS mx, COL(1) + 10 GET mGFontSty PICTURE '@^ Plain;Bold;Italic;Underline' FONT 'chicago',12
  170.     STORE mx + mleadingx TO mx
  171.     *-
  172.     *- Format of legends
  173.     *-
  174.     @ PIXELS mx, mleft1 SAY "Legend format"
  175.     @ PIXELS mx, mleft2 GET mFormat PICTURE "@^ General;Currency;Percent" FONT 'chicago',12
  176.     @ PIXELS mx, 250 SAY "Currency symbol"
  177.     @ PIXELS mx, COL(1) + 10 GET mCurrSym PICTURE 'X' FONT 'monaco',12
  178.     @ PIXELS mx, COL(1) + 15 GET mCurrSymPl PICTURE '@*C  After'
  179.     STORE mx + mleadingx TO mx
  180.     *-
  181.     *- Scaling
  182.     *-
  183.     IF mGraphType < 3
  184.         @ PIXELS mx, mleft1 GET mAutoScale PICTURE "@*C Auto Scaling" VALID 1000
  185.     ELSE
  186.         *- option isn't avaliable for pies
  187.         @ PIXELS mx, mleft1 SAY mAutoScale PICTURE "@*C Auto Scaling"
  188.     ENDIF
  189.     *-
  190.     @ PIXELS mx, 140 SAY "Start"
  191.     @ PIXELS mx, 250 SAY "End"
  192.     @ PIXELS mx, 360 SAY "Steps"
  193.     IF mGraphType < 3 
  194.         IF .NOT. mAutoScale
  195.             @ PIXELS mx, 180 GET mMin PICTURE '99999999' FONT 'monaco', 12
  196.             @ PIXELS mx, 285 GET mMax PICTURE '99999999' FONT 'monaco', 12
  197.         ELSE    
  198.             DO p50Screen WITH mx, 140, 12, VAL(SYS(1030,"Start"))
  199.             DO p50Screen WITH mx, 250, 12, VAL(SYS(1030,"End"))
  200.             @ PIXELS mx, 180 SAY mMin PICTURE '99999999' FONT 'monaco', 12
  201.             @ PIXELS mx, 285 SAY mMax PICTURE '99999999' FONT 'monaco', 12
  202.         ENDIF
  203.         @ PIXELS mx, 405 GET mSteps PICTURE '99999999' FONT 'monaco', 12
  204.     ELSE
  205.         *- option isn't avaliable for pies
  206.         DO p50Screen WITH mx, 140, 12, VAL(SYS(1030,"Start"))
  207.         DO p50Screen WITH mx, 250, 12, VAL(SYS(1030,"End"))
  208.         DO p50Screen WITH mx, 350, 12, VAL(SYS(1030,"Number"))
  209.         @ PIXELS mx, 180 SAY mMin PICTURE '99999999' FONT 'monaco', 12
  210.         @ PIXELS mx, 285 SAY mMax PICTURE '99999999' FONT 'monaco', 12
  211.         @ PIXELS mx, 405 SAY mSteps PICTURE '99999999' FONT 'monaco', 12
  212.     ENDIF
  213.     STORE mx + mleadingx TO mx
  214.     *-
  215.     *- X- and Y- axis options
  216.     *-
  217.     @ PIXELS mx, mleft1 SAY 'Show Labels'
  218.     IF mGraphType < 3
  219.         *- line or bar
  220.         @ PIXELS mx, COL(1) + 10 GET mShowXAxis PICTURE "@*C X-Axis"
  221.         @ PIXELS mx, COL(1) + 10 GET mShowYAxis PICTURE "@*C Y-Axis"
  222.         @ PIXELS mx,COL(1) + 15 SAY 'Show Grid'
  223.         @ PIXELS mx, COL(1) + 10 GET mShowXGrid PICTURE "@*C Vert"
  224.         @ PIXELS mx, COL(1) + 10 GET mShowYGrid PICTURE "@*C Horiz"
  225.     ELSE
  226.         @ PIXELS mx, COL(1) + 10 SAY mShowXAxis PICTURE "@*C X-Axis"
  227.         @ PIXELS mx, COL(1) + 10 SAY mShowYAxis PICTURE "@*C Y-Axis"
  228.         @ PIXELS mx,COL(1) + 15 SAY 'Show Grid'
  229.         @ PIXELS mx, COL(1) + 10 SAY mShowXGrid PICTURE "@*C Vert"
  230.         @ PIXELS mx, COL(1) + 10 SAY mShowYGrid PICTURE "@*C Horiz"
  231.     ENDIF
  232.     STORE mx + mleadingx TO mx
  233.     IF mGraphType < 3
  234.         @ PIXELS mx, mleft1 SAY mShowLeg PICTURE "@*C Show Legends"
  235.         @ PIXELS mx, 175 SAY mShowPct PICTURE "@*C Show %ages"
  236.         @ PIXELS mx, 330 SAY "Box width" 
  237.         DO p50Screen WITH mx, 330, 12, VAL(SYS(1030,"Box width"))
  238.         @ PIXELS mx, 405 SAY mWidth PICTURE '999' FONT 'monaco',12
  239.     ELSE
  240.         @ PIXELS mx, mleft1 GET mShowLeg PICTURE "@*C Show Legends"
  241.         @ PIXELS mx, 175 GET mShowPct PICTURE "@*C Show %ages"
  242.         @ PIXELS mx, 330 SAY "Box width" 
  243.         @ PIXELS mx, 405 GET mWidth PICTURE '999' FONT 'monaco',12
  244.     ENDIF
  245.     STORE mx + mleadingx TO mx
  246.     *-
  247.     *- Display controls for this dialog
  248.     @ PIXELS mbottom - 41, 22 SAY mBack PICTURE "@* \I1001"
  249.     IF .NOT. BOF() .AND. RECNO() > 1
  250.         @ PIXELS mbottom - 41, 22 GET mBack PICTURE "@* \I1001" VALID 1000
  251.     ELSE
  252.         *- gray out
  253.         DO p50Screen WITH mbottom - 9,22, 32, 32
  254.     ENDIF
  255.     @ PIXELS mbottom - 35,  60 GET mEdit PICTURE "@* Edit Data" SIZE 20,85 STYLE 1 VALID 1000
  256.     @ PIXELS mbottom - 35, 150 GET mLabl PICTURE "@* Labels" SIZE 20,85 STYLE 1 VALID 1000
  257.     @ PIXELS mbottom - 35, 240 GET mPlot PICTURE "@* Plot It" SIZE 20,85 STYLE 1 VALID 1000
  258.     @ PIXELS mbottom - 35, 330 GET mDone PICTURE "@* Done" SIZE 20,85 STYLE 1 VALID 1000
  259.     @ PIXELS mbottom - 41, 421 SAY mFwd PICTURE "@* \I1002"
  260.     IF .NOT. EOF() .AND. RECNO() < RECC()
  261.         @ PIXELS mbottom - 41, 421 GET mFwd PICTURE "@* \I1002" VALID 1000
  262.     ELSE
  263.         *- gray out
  264.         DO p50Screen WITH mbottom - 9, 421, 32, 32
  265.     ENDIF
  266.     READ
  267.     *
  268.     *- process action
  269.     *-
  270.     IF mDone = 1
  271.         *- done
  272.         EXIT
  273.     ENDIF
  274.     IF mEdit = 1
  275.         *- edit data
  276.         EDIT
  277.     ENDIF
  278.     IF mLabl = 1
  279.         *- edit label data
  280.         SELECT gLabels
  281.         EDIT
  282.         SELECT sample
  283.     ENDIF
  284.     IF mPlot = 1
  285.         *-
  286.         *- display a graph (see procedure below)
  287.         *- 
  288.         DO pPlotGraph
  289.     ENDIF
  290.     IF mBack = 1 .AND. RECNO() > 1
  291.         SKIP -1
  292.         DO pPlotGraph
  293.     ENDIF
  294.     IF mFwd = 1 .AND. RECNO() < RECC()
  295.         SKIP
  296.         DO pPlotGraph
  297.     ENDIF
  298.     *- loop back around and display new graph
  299. ENDDO
  300. *- cleanup and leave
  301. RELEASE MODULE plotGraph
  302. SET RESOURCE TO
  303. CLOSE DATABASE
  304. SCREEN 1 TOP SIZE mbottom, mright PIXELS HEADING "Screen 1" FONT 'chicago', 12
  305. CLEAR
  306. SCREEN 2 DELETE
  307. RETURN
  308. *- end of main program
  309.  
  310. *-
  311. *- PROCEDURE pPlotGraph
  312. *-
  313. *- takes care of plotting out data from the current record
  314. *- of SAMPLE.DBF
  315. *-
  316. *- use globals defined in main program above
  317. *-
  318. PROCEDURE pPlotGraph
  319. *-
  320. *- display a graph
  321. *- 
  322. IF mGraphType = 1 .OR. mGraphType = 2
  323.     *-
  324.     *- line or bar graph
  325.     *-
  326.     *-
  327.     *- 1. set number of points to graph
  328.     *-
  329.     STORE 12 TO mNumPoints
  330.     *-
  331.     *- 2. load up data strings
  332.     *-
  333.     STORE STR(sample->period1,10) + ;
  334.           STR(sample->period2,10) + ;
  335.           STR(sample->period3,10) + ;
  336.           STR(sample->period4,10) + ;
  337.           STR(sample->period5,10) TO mData1
  338.     STORE mdata1 + ;
  339.           STR(sample->period6,10) + ;
  340.           STR(sample->period7,10) + ;
  341.           STR(sample->period8,10) + ;
  342.           STR(sample->period9,10) + ;
  343.           STR(sample->period10,10) TO mData1
  344.     STORE mdata1 + ;
  345.           STR(sample->period11,10) + ;
  346.           STR(sample->period12,10) TO mData1
  347.     *-
  348.     *- 3. define outer rectangle for graph + legends + title
  349.     *-
  350.     STORE STR(mOLeft,5) + ;
  351.           STR(mOTop,5) + ;
  352.           STR(mORight,5) + ;
  353.           STR(mOBottom,5) to mORect
  354.     *-
  355.     *- 4. define inner rectangle for graph itself
  356.     *-
  357.     STORE STR(mGLeft,5) + ;
  358.           STR(mGTop,5) + ;
  359.           STR(mGRight,5) + ;
  360.           STR(mGBottom,5) to mGRect
  361.     *-
  362.     *- 5. set graph options
  363.     *-
  364.     STORE IIF(mGraphType = 1, 'L', 'B') + ;
  365.           SUBSTR('G$%', mFormat, 1) + ;
  366.           IIF(mShowXAxis, 'Y', 'N') + ;
  367.           IIF(mShowYAxis, 'Y', 'N') + ;
  368.           mCurrSym + ;
  369.           IIF(mCurrSymPl,'A','B') + ;
  370.           IIF(mAutoScale,'A','F') TO mGOpt
  371.     STORE mGOpt + ;
  372.           IIF( mShowXGrid, 'Y','N') + ;
  373.           IIF( mShowYGrid, 'Y','N') TO mGOpt
  374.      *-
  375.     *- 6. set font, size and style for graph legends
  376.     *-
  377.     STORE TRIM(mGFontNam) + ';' + ;
  378.           LTRIM(STR(mGFontSiz + IIF(mGFontSty = 1, 0, 2 ^ (6 + mGFontSty)),5)) TO mGFont       && Graph font: font; size + style (used for labels)
  379.     *-
  380.     *- 7. set graph title, font, size and style
  381.     *-
  382.     STORE TRIM(mGTitle) + ';' + ;
  383.           TRIM(mGTFontNam) + ';' + ;
  384.           LTRIM(STR(mGTFontSiz + IIF(mGTFontSty = 1, 0, 2 ^ (6 + mGTFontSty)),5)) to mGTitl    && Graph title: title; font; size + style
  385.     *-
  386.     *- 8. set values for Legend box
  387.     *-
  388.     STORE GLabels->x1 + ;
  389.           GLabels->x2 + ;
  390.           GLabels->x3 + ;
  391.           GLabels->x4 + ;
  392.           GLabels->x5 + ;
  393.           GLabels->x6 + ;
  394.           GLabels->x7 + ;
  395.           GLabels->x8 + ;
  396.           GLabels->x9 + ;
  397.           GLabels->x10 + ;
  398.           GLabels->x11 + ;
  399.           GLabels->x12 TO mXLeg
  400.     *-
  401.     *- 9. set min and max
  402.     *-
  403.     STORE STR(IIF(mAutoScale, 0, mMin),10) + STR(IIF(mAutoScale, 0, mMax),10) + STR(mSteps,10) to mGMinMax
  404. ELSE
  405.     *-
  406.     *- pie chart
  407.     *-
  408.     *-
  409.     *- 1. set number of points to graph
  410.     *-
  411.     STORE 5 TO mNumPoints
  412.     *-
  413.     *- 2. load up data strings
  414.     *-
  415.     STORE STR(sample->hardware,10) + ;
  416.           STR(sample->software,10) + ;
  417.           STR(sample->program,10) + ;
  418.           STR(sample->techsupp,10) + ;
  419.           STR(sample->consult,10) TO mData1
  420.     *-
  421.     *- 3. define outer rectangle for graph + legends + title
  422.     *-
  423.     STORE STR(mOLeft,5) + ;
  424.           STR(mOTop,5) + ;
  425.           STR(mORight,5) + ;
  426.           STR(mOBottom,5) to mORect
  427.     *-
  428.     *- 4. define inner rectangle for graph itself
  429.     *-
  430.     STORE STR(mGLeft,5) + ;
  431.           STR(mGTop,5) + ;
  432.           STR(mGRight,5) + ;
  433.           STR(mGBottom,5) to mGRect
  434.     *-
  435.     *-
  436.     *- 5. set graph options
  437.     *-
  438.     STORE 'P' + ;
  439.           SUBSTR('G$%', mFormat, 1) + ;
  440.           IIF(mShowLeg, 'Y', 'N') + ;
  441.           IIF(mShowPct, 'Y', 'N') + ;
  442.           mCurrSym + ;
  443.           IIF(mCurrSymPl,'A','B') + ;
  444.           'F' + '  ' TO mGOpt
  445.     *-
  446.     *- 6. set font, size and style for graph legends
  447.     *-
  448.     STORE TRIM(mGFontNam) + ';' + ;
  449.           LTRIM(STR(mGFontSiz + IIF(mGFontSty = 1, 0, 2 ^ (6 + mGFontSty)),5)) TO mGFont       && Graph font: font; size + style (used for labels)
  450.     *-
  451.     *- 7. set graph title, font, size and style
  452.     *-
  453.     STORE TRIM(mGTitle) + ';' + ;
  454.           TRIM(mGTFontNam) + ';' + ;
  455.           LTRIM(STR(mGTFontSiz + IIF(mGTFontSty = 1, 0, 2 ^ (6 + mGTFontSty)),5)) to mGTitl    && Graph title: title; font; size + style
  456.     *-
  457.     *- 8. set values for X-Axis legend
  458.     *-
  459.     STORE GLabels->Slice1 + ;
  460.           GLabels->Slice2 + ;
  461.           GLabels->Slice3 + ;
  462.           GLabels->Slice4 + ;
  463.           GLabels->Slice5  TO mXLeg
  464.     *-
  465.     *- 9. set maximum value for graph, or 0 if auto-scaling
  466.     *-
  467.     STORE mWidth to mGMinMax
  468. ENDIF && which graph type
  469. *-
  470. *- At last, call the XFCN
  471. *-
  472. SCREEN 2 LOCK
  473. IF mORight <> mORightX .OR. mOLeft <> mOLeftX .OR. mOBottom <> mOBottomX .OR. mOTop <> mOTopX
  474.     *- outer rectangle changed, so clear area, just in case
  475.     CLEAR
  476.     *- and remember new values
  477.     STORE mORight TO mORightX
  478.     STORE mOLeft TO mOLeftX
  479.     STORE mOBottom TO mOBottomX
  480.     STORE mOTop TO mOTopX
  481. ENDIF
  482. CALL plotGraph TO mResult WITH mNumPoints, mData1, mData2 , mORect, mGRect, mGOpt, mGFont, mGTitl, mXLeg, mGMinMax
  483. *-
  484. *- may have been an error in paramters, so check
  485. *-
  486. *- "0" = no error
  487. *- "1" = wrong number of parameters was passed
  488. *- "2" = grect extends beyond orect, or pie chart and grect isn't square
  489. IF VAL(mresult) > 0
  490.   DO CASE
  491.     CASE mresult = "1"
  492.       STORE "Wrong number of parameters" TO merror
  493.     CASE mresult = "2"
  494.       STORE "Graph rectangle must be completely within outer rectangle" TO merror
  495.     CASE mresult = "3"
  496.       STORE "Graph rectangle must be square for pie graphs" TO merror
  497.     CASE mresult = "4"
  498.       STORE "Too many data points — max is 10 for a pie chart, 50 for line and bar graphs" TO merror
  499.     OTHERWISE
  500.       STORE "Unknown error" TO merror
  501.   ENDCASE
  502.   ALERT NOTE 8 "Error calling plotGraph: " + merror + ". (" + mresult + ")"
  503. ELSE
  504.   *- save graph as picture, for later printing
  505.   SAVE SCREEN TO aGraph AT mOTop,mOLeft SIZE mOBottom - mOTop, mORight - mOLeft PIXELS
  506.   IF mGraphType < 3
  507.     *- line or bar
  508.     REPLACE saleGraph WITH aGraph
  509.   ELSE
  510.     REPLACE mixGraph WITH aGraph
  511.   ENDIF
  512. ENDIF
  513. SCREEN 1 LOCK TOP
  514. RETURN
  515. *- eop pPlotGraph
  516.  
  517. *-
  518. *- PROCEDURE pScreen
  519. *-
  520. * ' 50% screen on rectangle (mx - mh,my to mx + 3,my + mw + 3)
  521. *-
  522. PROCEDURE p50Screen
  523. PARAMETERS mrow, mcol, mheight, mwid
  524. *-
  525. @ PIXELS mrow - mheight,mcol TO mrow + 3,mcol + mwid + 3 STYLE 198664
  526. RETURN
  527. *- eop p50Screen
  528.  
  529. *- end of Demo.PRG
  530.